//
// Created by blank on 2017/5/8.
// Copyright (c) 2017 CYN. All rights reserved.
//

#import "Presenter.h"
#import "MVPView.h"
#import "MVPModel.h"
#import "ServiceFactory.h"
#import "PrintService.h"

@interface Presenter () <MVPViewDelegate>

@end

@implementation Presenter {

}


- (MVPView *)mvpView {
    if (!_mvpView) {
        _mvpView = [[MVPView alloc] init];
        [_mvpView setDelegate:self];
        [_mvpView setFrame:CGRectMake(0, 0, 300, 500)];
    }
    return _mvpView;
}

- (MVPModel *)mvpModel {
    if (!_mvpModel) {
#if 0
        _mvpModel = [[MVPModel alloc] init];
        [_mvpModel setContent:@"line0"];
#else
        _mvpModel = [[ServiceFactory instance].printService printModel];

#endif
    }
    return _mvpModel;
}

- (void)printTask {
    [self.mvpView printOnView:self.mvpModel.content];
}

- (void)onPrintBtnClick {
    [self.mvpModel setContent:[NSString stringWithFormat:@"line %u", arc4random() % 10]];
    [self printTask];
}


@end